package com.example.demoface.controller;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClient;
import com.aliyun.oss.model.PutObjectRequest;
import com.aliyun.oss.model.PutObjectResult;
import com.example.demoface.domian.ResponseResult;
import com.example.demoface.service.impl.BaiduFaceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;



@RestController
public class Api {

    @Autowired
    private OSS ossClient;

    @Autowired
    private BaiduFaceService baiduFaceService;

    @GetMapping("/example")
    public String exampleMethod(@RequestParam int param1, @RequestParam int param2) {
        // 处理逻辑
        int result = param1 + param2;
        return "Result: " + result;
    }

    @PostMapping("/upload")
    public ResponseEntity<Map> handleFileUpload(@RequestParam("file") MultipartFile file) throws IOException {
        PutObjectRequest putObjectRequest = new PutObjectRequest("wqwqwqq", file.getName(), file.getInputStream());
        PutObjectResult putObjectResult = ossClient.putObject(putObjectRequest);
        return null;


    }

}
